<template>
  <div>
    <div class="container">
      <div class="handle-box">
        <el-select v-model="query.case_source" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件来源" class="handle-select mr10">
          <el-option key="1" label="市场查获" value="市场查获"></el-option>
          <el-option key="2" label="投诉举报" value="投诉举报"></el-option>
          <el-option key="3" label="上级交办" value="上级交办"></el-option>
        </el-select>
        <el-select v-model="query.case_type" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件性质" class="handle-select mr10">
          <el-option key="1" label="一般案件" value="一般案件"></el-option>
          <el-option key="2" label="简易案件" value="简易案件"></el-option>
        </el-select>
        <el-input v-model="query.case_number" placeholder="立案编号" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" class="handle-input mr10"></el-input>
        <el-button type="primary" :icon="Search" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)">搜索</el-button>
      </div>

      <el-table :data="tableList" border class="table" ref="multipleTable" header-cell-class-name="table-header">
        <!--        <el-table-column prop="case_id" label="案件号" width="100" align="center"></el-table-column>-->
        <el-table-column prop="case_source" label="案件来源" align="center"></el-table-column>
        <el-table-column prop="case_number" label="立案编号"  align="center"></el-table-column>
        <el-table-column prop="case_update_time" label="更新时间"  align="center"></el-table-column>
        <el-table-column prop="case_type" label="案件性质" align="center"></el-table-column>
        <el-table-column prop="date_of_filing" label="立案日期"  align="center"></el-table-column>
        <el-table-column prop="tcs_note_id" label="状态" width="230" align="center"></el-table-column>
        <el-table-column label="操作" width="150" align="center">
          <template #default="scope">
            <div v-if="scope.row.tcs_note_id === '证据先行保存批准书已完成' " >
              <el-button text :icon="Edit" class="blue" @click="ratification_tabel(scope.row)" v-permiss="12" >
                审 核
              </el-button>
            </div>
            <div v-if="scope.row.tcs_note_id === '立案报告表已完成' ">
              <el-button text :icon="Edit" class="blue" @click="views_case_report_data_1(scope.row)" v-permiss="17">
                审 核
              </el-button>
            </div>
            <div v-if="scope.row.tcs_note_id === '立案报告表主任审核已完成'" >
              <el-button text :icon="Edit" class="blue" @click="views_case_report_data_2(scope.row)" v-permiss="18">
                审 核
              </el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination
            background
            layout="total, prev, pager, next"
            :current-page="query.pageIndex"
            :page-size="query.pageSize"
            :total="pageTotal"
            @current-change="handlePageChange"
        ></el-pagination>
      </div>
    </div>

    <el-dialog title="证据先行保存批准书审核" v-model="Ratification_Visible" width="70%" >
      <el-table :data="evidence_case_Data" border class="table" ref="multipleTable" header-cell-class-name="table-header">
        <el-table-column prop="case_id" label="案件号"  align="center"></el-table-column>
        <el-table-column prop="evi_id_number" label="证据先行保存批准书编号"  width="200" align="center"></el-table-column>
        <el-table-column prop="tce_number" label="烟草数量"  align="center"></el-table-column>
        <el-table-column prop="tce_amount" label="烟草价值"  align="center"></el-table-column>
        <el-table-column label="操作" width="220" align="center">
          <template #default="scope">
            <el-button text :icon="Edit" @click="get_case_evidenct_data(scope.row)" >
              查 看
            </el-button>
            <el-button text :icon="Edit" @click="create_evi_word(scope.row)" >
              打 印
            </el-button>
          </template>
        </el-table-column>
      </el-table>
<br>
<!--      <el-form-item >-->
<!--        <el-input type="textarea" v-model="case_report_data.review_commets" rows="2" placeholder="请输入审核意见" ></el-input>-->
<!--      </el-form-item>-->

      <template #footer>
				<span class="dialog-footer">
					<el-button @click="Ratification_Visible = false">取 消</el-button>
          <el-button type="success" @click="Ratif_process_success" >审核通过</el-button>
          <el-button type="danger" @click="Ratif_process_fail" >审核不通过</el-button>
				</span>
      </template>
    </el-dialog>


    <!--    //查看证据先行保存批准书-->
    <el-dialog title="" v-model="Ratification_Edit_Visible" width="34%">
      <html>
      <head>
        <title>证据先行保存批准书</title>
      </head>
      <body>
      <h1 align="center">
        福建省闽侯县烟草专卖局
      </h1>
      <h2 align="center">
        证据先行保存批准书
      </h2>
      <h3 align="center">
        侯烟存准【<b><u>{{case_evi_data.year}}</u></b>】第<b><u>{{case_evi_data.evi_id_number}}</u></b>号
      </h3>
      <div>
        <br><br>
      </div>
      <p>
        因 <b><u> {{ case_evi_data.mer_person }} </u></b> 涉嫌 <b><u>{{ case_evi_data.illegal_behavior }} </u></b>
        行为违反《中华人民共和国烟草专卖法》及实施条例等法律法规的有关规定，根据《中华人民共和国行政处罚法》
        第三十七条第二款的规定，现拟对下列物品予以先行登记保存：
      </p>
      <table border="1" style="border-collapse: collapse;" width="100%" >
        <tr>
          <th  width="25%">品种</th>
          <th  width="30%">条条形码</th>
          <th  width="25%">规格型号</th>
          <th  width="5%">单位</th>
          <th  width="10%">数量</th>
        </tr>
      </table>
      <div v-for="item in evidence_ciga_Data">
        <table border="1" style="border-collapse: collapse;" width="100%">
          <tr>
            <th  width="25%">{{item.ciga_variety}}</th>
            <th width="30%"> {{ item.barcode }}</th>
            <th  width="25%">{{ item.ciga_model }}</th>
            <th  width="5%">条</th>
            <th  width="10%">{{ item.evi_number }}</th>
          </tr>
        </table>
      </div>
      <table border="1" style="border-collapse: collapse;" width="100%">
        <tr>
          <th >
            <span style="text-align: left">共计： <b><u>{{ case_evi_data.tce_type_number_chinese }}</u></b>品种</span>
          </th>
          <th >
            <span style="text-align: right">总计： <b><u>{{ case_evi_data.tce_number_chinese }}</u></b></span>
          </th>
        </tr>
        <tr>
          <th>登记保存地点</th>
          <th>
            <b><u>{{case_evi_data.tce_address}}</u></b>
          </th>
        </tr>
      </table>
      <p style="font-size: 15px">
        登记保存证据的保存期限为七日。
      </p>
      <p style="font-size: 15px">
        承办人（签名）：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
        <b><u>&emsp;&emsp;&emsp;&emsp;{{case_evi_data.user_name_1}}&emsp;&emsp;&emsp;&emsp;</u></b><br>
        &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
        <b><u>&emsp;&emsp;&emsp;&emsp;{{case_evi_data.user_name_2}}&emsp;&emsp;&emsp;&emsp;</u></b>
      </p>
      <p align="right" style="font-size: 15px">
        <b><u> {{ case_evi_data.year }}</u></b>年  <b><u>{{ case_evi_data.month }}</u></b> 月  <b><u>{{ case_evi_data.day }}</u></b> 日
      </p>
      </body>
      </html>
    </el-dialog>


    <!--    //查看立案报告表-->
    <el-dialog title="" v-model="View_report_Visible_1" width="34%">
      <html>
      <head>
        <title>立案报告表</title>
      </head>
      <body>
      <h1 align="center">
        福建省闽侯县烟草专卖局
      </h1>
      <h2 align="center">
        立案报告表
      </h2>
      <h3 align="center">
        侯烟立【<b><u>{{case_report_data.year}}</u></b>】第<b><u>{{case_report_data.case_number}}</u></b>号
      </h3>

      <table border="1" style="border-collapse: collapse;" width="100%">
        <tr>
          <th colspan="1" width="25%">案由</th>
          <th colspan="3">{{case_report_data.illegal_behavior_data}}</th>
        </tr>
        <tr>
          <th>案件来源</th>
          <th colspan="3">{{case_report_data.case_source}}</th>
        </tr>
        <tr>
          <th>发案时间</th>
          <th>{{case_report_data.year}}年{{case_report_data.month}}月{{case_report_data.day}}日
            {{case_report_data.hour}}时{{case_report_data.min}}分
          </th>
          <th>发案地点</th>
          <th>{{case_report_data.mer_address}}</th>
        </tr>
        <tr>
          <th>当事人</th>
          <th>{{case_report_data.tir_person}}</th>
          <th>证件类型及号码</th>
          <th>许可证号：{{case_report_data.retail_licence_code}}<br>
            身份证：{{case_report_data.tir_id_number}}
          </th>
        </tr>
        <tr>
          <th>住址</th>
          <th colspan="3">{{case_report_data.mer_hometown}}</th>
        </tr>
        <tr>
          <th>案情摘要</th>
          <th colspan="3" align="left">{{case_report_data.year}}年{{case_report_data.month}}月{{case_report_data.day}}日
            {{case_report_data.hour}}时，我局专卖执法人员在闽侯县{{ case_report_data.area_name }}进行{{ case_report_data.case_source }}，
            检查至{{ case_report_data.mer_address }}，依法对闽侯县{{ case_report_data.area_name }}{{ case_report_data.mer_name }}的当事人
            {{ case_report_data.tir_person }}出示执法检查证件表明身份后，
            依法对该店铺进行检查，在该店卷烟柜台内发现一批未印有“由中国烟草总公司专卖”字样的外国卷烟，品种数量如下:
            {{case_report_data.ciga_data}}
            总计{{ case_report_data.tce_type_number_chinese }}个品种{{ case_report_data.tce_number_chinese }}
            （具体品种详见先行登记保存通知书,单号{{case_report_data.evi_data}}）。
            由于当事人无法提供购买该批卷烟的合法有效证明，涉嫌 {{case_report_data.illegal_behavior_data}}的行为。为了保全证据，我局专卖执法人员对现场执法情况拍照留证，
            经本局领导批准同意，我局专卖执法人员依法对上述卷烟予以先行登记保存，同时制作检查（勘验）笔录，交当事人{{case_report_data.tir_person}}核对无异议后签字确认。</th>
        </tr>
        <tr>
          <th>承办人意见</th>
          <th colspan="3" align="left">当事人的行为涉嫌违反了《福建省反走私综合治理工作规定》第十三条的规定。根据《烟草专卖行政处罚程序规定》第十六条第（一）项的规定，建议立案调查，进一步查清案件事实。<br><br>
            签名：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;日期：&emsp;年&emsp;月&emsp;日<br><br><br></th>
        </tr>
        <tr>
          <th>承办部门意见</th>
          <th colspan="3" align="left"><br><br>
            签名：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;日期：&emsp;年&emsp;月&emsp;日<br><br><br></th>
        </tr>
        <tr>
          <th>领导意见</th>
          <th colspan="3" align="left"><br><br>
            签名：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;日期：&emsp;年&emsp;月&emsp;日<br><br><br></th>
        </tr>
      </table>
      </body>
      </html>
      <br>
<!--      <el-form-item  >-->
<!--        <el-input type="textarea" v-model="case_report_data.review_commets" rows="2" placeholder="请输入审核意见"></el-input>-->
<!--      </el-form-item>-->
      <template #footer>
				<span class="dialog-footer">
					<el-button @click="View_report_Visible_1 = false">取 消</el-button>
          <el-button type="success" @click="report_process_success_1" >审核通过</el-button>
          <el-button type="danger" @click="report_process_fail_1" >审核不通过</el-button>
          <el-button type="primary" @click="create_report_word" >打 印</el-button>
				</span>
      </template>
    </el-dialog>
    <!--    //查看立案报告表-->
    <el-dialog title="" v-model="View_report_Visible_2" width="34%">
      <html>
      <head>
        <title>立案报告表</title>
      </head>
      <body>
      <h1 align="center">
        福建省闽侯县烟草专卖局
      </h1>
      <h2 align="center">
        立案报告表
      </h2>
      <h3 align="center">
        侯烟立【<b><u>{{case_report_data.year}}</u></b>】第<b><u>{{case_report_data.case_number}}</u></b>号
      </h3>

      <table border="1" style="border-collapse: collapse;" width="100%">
        <tr>
          <th colspan="1" width="25%">案由</th>
          <th colspan="3">{{case_report_data.illegal_behavior_data}}</th>
        </tr>
        <tr>
          <th>案件来源</th>
          <th colspan="3">{{case_report_data.case_source}}</th>
        </tr>
        <tr>
          <th>发案时间</th>
          <th>{{case_report_data.year}}年{{case_report_data.month}}月{{case_report_data.day}}日
            {{case_report_data.hour}}时{{case_report_data.min}}分
          </th>
          <th>发案地点</th>
          <th>{{case_report_data.mer_address}}</th>
        </tr>
        <tr>
          <th>当事人</th>
          <th>{{case_report_data.tir_person}}</th>
          <th>证件类型及号码</th>
          <th>许可证号：{{case_report_data.retail_licence_code}}<br>
            身份证：{{case_report_data.tir_id_number}}
          </th>
        </tr>
        <tr>
          <th>住址</th>
          <th colspan="3">{{case_report_data.mer_hometown}}</th>
        </tr>
        <tr>
          <th>案情摘要</th>
          <th colspan="3" align="left">{{case_report_data.year}}年{{case_report_data.month}}月{{case_report_data.day}}日
            {{case_report_data.hour}}时，我局专卖执法人员在闽侯县{{ case_report_data.area_name }}进行{{ case_report_data.case_source }}，
            检查至{{ case_report_data.mer_address }}，依法对闽侯县{{ case_report_data.area_name }}{{ case_report_data.mer_name }}的当事人
            {{ case_report_data.tir_person }}出示执法检查证件表明身份后，
            依法对该店铺进行检查，在该店卷烟柜台内发现一批未印有“由中国烟草总公司专卖”字样的外国卷烟，品种数量如下:
            {{case_report_data.ciga_data}}
            总计{{ case_report_data.tce_type_number_chinese }}个品种{{ case_report_data.tce_number_chinese }}
            （具体品种详见先行登记保存通知书,单号{{case_report_data.evi_data}}）。
            由于当事人无法提供购买该批卷烟的合法有效证明，涉嫌 {{case_report_data.illegal_behavior_data}}的行为。为了保全证据，我局专卖执法人员对现场执法情况拍照留证，
            经本局领导批准同意，我局专卖执法人员依法对上述卷烟予以先行登记保存，同时制作检查（勘验）笔录，交当事人{{case_report_data.tir_person}}核对无异议后签字确认。</th>
        </tr>
        <tr>
          <th>承办人意见</th>
          <th colspan="3" align="left">当事人的行为涉嫌违反了《福建省反走私综合治理工作规定》第十三条的规定。根据《烟草专卖行政处罚程序规定》第十六条第（一）项的规定，建议立案调查，进一步查清案件事实。<br><br>
            签名：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;日期：&emsp;年&emsp;月&emsp;日<br><br><br></th>
        </tr>
        <tr>
          <th>承办部门意见</th>
          <th colspan="3" align="left"><br><br>
            签名：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;日期：&emsp;年&emsp;月&emsp;日<br><br><br></th>
        </tr>
        <tr>
          <th>领导意见</th>
          <th colspan="3" align="left"><br><br>
            签名：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;日期：&emsp;年&emsp;月&emsp;日<br><br><br></th>
        </tr>
      </table>
      </body>
      </html>
<br>
<!--      <el-form-item  >-->
<!--      <el-input type="textarea" rows="2" v-model="case_report_data.review_commets" placeholder="请输入审核意见"></el-input>-->
<!--    </el-form-item>-->


      <template #footer>

				<span class="dialog-footer">
					<el-button @click="View_report_Visible_2 = false">取 消</el-button>
          <el-button type="success" @click="report_process_success_2" >审核通过</el-button>
          <el-button type="danger" @click="report_process_fail_2" >审核不通过</el-button>
          <el-button type="primary" @click="create_report_word" >打 印</el-button>
				</span>
      </template>
    </el-dialog>


  </div>
</template>

<script setup lang="ts" name="basetable">
import { ref, reactive } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { Delete, Edit, Search, Plus } from '@element-plus/icons-vue';
import {
  case_evi_Create,
  case_evi_Views,
  case_legal_Create,
  ciga_evudence_Create,
  end_record_data,
  evi_Views,
  fetchData_case,
  fetchData_case_Create,
  fetchData_case_update,
  fetchData_legal_clause,
  fetchData_mer,
  fetchData_s_mongodb_evidence_Cre,
  fetchData_s_mongodb_evidence_Views,
  fetchData_tobacco,
  fetchData_user,
  illegal_record_data,
  illegal_record_Search,
  mer_Create,
  mer_search_api,
  review_price_data,
  staff_evidence_create,
  staff_evidence_data,
  end_record_show,
  record_inquiry_show,
  record_inquiry_print,
  case_evidence_Views, case_evidence_Edit, fetch_examine_case, inspection_judge_state, fetchData_examine_case, fetchData_case2
} from '../api/index';
import {
  export_word_1, export_word_3,
} from './table_inquiry.vue'

//案件表数据
interface TableItem {
  case_id:number,
  date_of_filing:string,
  date_of_closing:string,
  date_of_archive:string,
  case_source:string,
  case_number:string,
  archive_person:string,
  case_update_time:string,
  ase_type:string,
  case_remark:string,
  tcs_note_id:string,
  ciga_flag:string,
  ciga_num_flag:string,
  mer_flag:string,
}

// 暂存立案报告表数据
const case_report_data = reactive({
  year:'',
  month:'',
  day:'',
  hour:'',
  min:'',
  tcs_note:'',
  case_id:0,
  case_source:'',
  case_number:'',
  date_of_filing:'',
  mer_address:'',
  mer_person:'',
  mer_id_number:'',
  mer_hometown:'',
  mer_name:'',
  retail_licence_code:'',
  area_name:'',
  tce_type_number:'',
  tce_number:'',
  tce_type_number_chinese:'',
  tce_number_chinese:'',
  mer_id:'',
  tir_id_number:'',
  tir_person:'',
  list1:[],
  list2:[],
  list3:[],
  illegal_behavior_data : '',
  ciga_data : '',
  evi_data : '',
  review_commets:'',
})


//视图/

const Ratification_Visible = ref(false);                              //批准书视图
const Ratification_Edit_Visible = ref(false);                         //批准书修改视图
const View_report_Visible_1 = ref(false);                               //查看立案报告书视图(主任)
const View_report_Visible_2 = ref(false);                               //查看立案报告书视图（局长）

//通过案件号查询所有证据先行保存通知书
interface Evidence_case_data {
  case_id:number,//案件号
  evi_id_number:string,
  evi_number:number,
  tce_time_year:string,//案件时间
  tce_time_month:string,
  tce_time_day:string,
  tce_type_number:string,
  tce_number:string,
  tce_amount:number,
  tce_remark:string,
  tce_address:string,
}
const evidence_case_Data= ref<Evidence_case_data[]>([]);
const get_evidence_case_Data = (case_id:number) =>{
  case_evi_Views("" ,case_id).then(res=>{
    evidence_case_Data.value = res.data.data;
  })
}

//打印证据先行保存批准书
const create_evi_word = (row:any) =>{
  case_evidence_Views(row.case_id,row.evi_id_number).then(res=>{
    export_word_1(res.data.data.evi_id_number,
        res.data.data.illegal_behavior,
        res.data.data.mer_person,
        res.data.data.year,
        res.data.data.month,
        res.data.data.day,
        res.data.data.user_name_1, //执法人员1
        res.data.data.user_name_2,//执法人员2
        res.data.data.tce_type_number_chinese,
        res.data.data.tce_number_chinese,
        res.data.data.tce_address,
        res.data.data.list
    )
  })
}
//打印立案报告书
const create_report_word = () =>{
  illegal_record_data(case_report_data.case_id).then(res=>{
    export_word_3(
        res.data.data.year,
        res.data.data.case_number,
        res.data.data.list1,
        res.data.data.case_source,
        res.data.data.month,
        res.data.data.day,
        res.data.data.hour,
        res.data.data.min,
        res.data.data.mer_address,
        res.data.data.tir_person,
        res.data.data.retail_licence_code,
        res.data.data.tir_id_number,
        res.data.data.mer_hometown,
        res.data.data.area_name,
        res.data.data.mer_name,
        res.data.data.list2,
        res.data.data.tce_type_number_chinese,
        res.data.data.tce_number_chinese,
        res.data.data.list3,
    )
  })
}

interface Evidence_ciga_data {
  case_id:number,
  evi_number:number,
  ciga_variety:string,
  barcode:string,
  ciga_model:string,
  ciga_price:number,
  inkjet:string,
  evi_id_number:string,
}
const evidence_ciga_Data= ref<Evidence_ciga_data[]>([]);
// 暂存先行保存批准书数据
const case_evi_data = reactive({
  date_of_filing:'',
  year:'',
  month:'',
  day:'',
  evi_id_number:'',
  evi_id_number1:'',
  illegal_behavior:'',
  tlc_id:'',
  mer_person:'',
  mer_id:'',
  tce_type_number:'',
  tce_number:'',
  tce_type_number_chinese:'',
  tce_number_chinese:'',
  tce_address:'',
  user_id_1:'',
  user_id_2:'',
  user_name_1:'',
  user_name_2:'',
})
//获取证据先行保存通知书中的信息
const get_case_evidenct_data = (row:any) =>{
  case_evidence_Views(row.case_id,row.evi_id_number).then(res=>{
        case_evi_data.date_of_filing = res.data.data.date_of_filing;
        case_evi_data.year = res.data.data.year
        case_evi_data.month = res.data.data.month
        case_evi_data.day = res.data.data.day
        case_evi_data.evi_id_number = res.data.data.evi_id_number
        case_evi_data.evi_id_number1 = res.data.data.evi_id_number
        case_evi_data.illegal_behavior = res.data.data.illegal_behavior
        case_evi_data.tlc_id = res.data.data.tlc_id
        case_evi_data.mer_person = res.data.data.mer_person
        case_evi_data.mer_id = res.data.data.mer_id
        case_evi_data.tce_type_number = res.data.data.tce_type_number
        case_evi_data.tce_number = res.data.data.tce_number
        case_evi_data.tce_type_number_chinese = res.data.data.tce_type_number_chinese
        case_evi_data.tce_number_chinese = res.data.data.tce_number_chinese
        case_evi_data.tce_address = res.data.data.tce_address
        case_evi_data.user_id_1 = res.data.data.user_id_1
        case_evi_data.user_id_2 = res.data.data.user_id_2
        case_evi_data.user_name_1 = res.data.data.user_name_1
        case_evi_data.user_name_2 = res.data.data.user_name_2
        evidence_ciga_Data.value = res.data.data.list
      }
  )
  Ratification_Edit_Visible.value = true;
}
//获取立案报告表中的数据
const get_case_report_data= (row:any) =>{
  case_report_data.case_id = row.case_id
  illegal_record_data(row.case_id).then(res=>{
        case_report_data.year= res.data.data.year;
        case_report_data.month = res.data.data.month;
        case_report_data.day = res.data.data.day;
        case_report_data.hour = res.data.data.hour;
        case_report_data.min = res.data.data.min;
        case_report_data.case_source = res.data.data.case_source;
        case_report_data.case_number = res.data.data.case_number
        case_report_data.date_of_filing = res.data.data.date_of_filing
        case_report_data.mer_address = res.data.data.mer_address
        case_report_data.mer_person = res.data.data.mer_person
        case_report_data.mer_id = res.data.data.mer_id
        case_report_data.mer_id_number = res.data.data.mer_id_number
        case_report_data.mer_hometown = res.data.data.mer_hometown
        case_report_data.mer_name = res.data.data.mer_name
        case_report_data.mer_person = res.data.data.mer_person
        case_report_data.retail_licence_code = res.data.data.retail_licence_code
        case_report_data.tce_type_number = res.data.data.tce_type_number
        case_report_data.tce_number = res.data.data.tce_number
        case_report_data.tce_type_number_chinese = res.data.data.tce_type_number_chinese
        case_report_data.tce_number_chinese = res.data.data.tce_number_chinese
        case_report_data.tir_person = res.data.data.tir_person
        case_report_data.tir_id_number = res.data.data.tir_id_number
        res.data.data.list1.forEach(function (item) {
          case_report_data.illegal_behavior_data = case_report_data.illegal_behavior_data + item.illegal_behavior + '、'
        })
        res.data.data.list2.forEach(function (item) {
          case_report_data.ciga_data = case_report_data.ciga_data + '“' + item.ciga_model + ' ' + item.ciga_variety +
              '“'+item.evi_number+'条，'
        })
        res.data.data.list3.forEach(function (item) {
          case_report_data.evi_data = case_report_data.evi_data + '侯烟存通字【'+ case_report_data.year +'】第'+
              item.evi_id_number + '号、'
        })
      }
  )
}

//证据先行保存批准书审核通过按钮
const Ratif_process_success = () =>{
  case_report_data.tcs_note = "证据先行保存通知书审核已完成"
  fetchData_case_update(case_report_data.case_id,case_report_data.tcs_note).then(res=>{
    if (res.data.message === "success"){
      ElMessage.success('证据先行保存通知书审核已完成');
      getData();
      Ratification_Visible.value = false;
    }else {
      ElMessageBox.confirm('操作失败', '提示', {
        type: 'warning'
      })
    }
  })
}
//审核未通过按钮
const Ratif_process_fail = () =>{
  case_report_data.tcs_note = "证据采集已完成"
  fetchData_case_update(case_report_data.case_id,case_report_data.tcs_note).then(res=>{
    if (res.data.message === "success"){
      ElMessage.success('操作成功');
      getData();
      Ratification_Visible.value = false;
    }else {
      ElMessageBox.confirm('操作失败', '提示', {
        type: 'warning'
      })
    }
  })
}
//立案报告表主任审核通过按钮
const report_process_success_1 = () =>{
  case_report_data.tcs_note = "立案报告表主任审核已完成"
  fetchData_case_update(case_report_data.case_id,case_report_data.tcs_note).then(res=>{
    if (res.data.message === "success"){
      ElMessage.success('立案报告表主任审核已完成');
      getData();
      View_report_Visible_1.value = false;
    }else {
      ElMessageBox.confirm('操作失败', '提示', {
        type: 'warning'
      })
    }
  })
}
//审核未通过按钮
const report_process_fail_1 = () =>{
  case_report_data.tcs_note = "喷码记录表已完成"
  fetchData_case_update(case_report_data.case_id,case_report_data.tcs_note).then(res=>{
    if (res.data.message === "success"){
      ElMessage.success('操作成功');
      getData();
      View_report_Visible_1.value = false;
    }else {
      ElMessageBox.confirm('操作失败', '提示', {
        type: 'warning'
      })
    }
  })
}

const report_process_success_2 = () =>{
  //判断是否全部都是单种卷烟大于50条
  inspection_judge_state(case_report_data.case_id).then(res=>{
    case_report_data.tcs_note=res.data.data.tcs_note;
    fetchData_case_update(case_report_data.case_id,case_report_data.tcs_note).then(res=>{
      if (res.data.message === "success"){
        ElMessage.success('立案报告表审核已完成');
        getData();
        View_report_Visible_2.value = false;
      }else {
        ElMessageBox.confirm('操作失败', '提示', {
          type: 'warning'
        })
      }
    })
  })

}


//审核未通过按钮
const report_process_fail_2 = () =>{
  case_report_data.tcs_note = "喷码记录表已完成"
  fetchData_case_update(case_report_data.case_id,case_report_data.tcs_note).then(res=>{
    if (res.data.message === "success"){
      ElMessage.success('操作成功');
      getData();
      View_report_Visible_2.value = false;
    }else {
      ElMessageBox.confirm('操作失败', '提示', {
        type: 'warning'
      })
    }
  })
}

//列表中的按钮
//证据先行保存批准书审核按钮
const ratification_tabel = (row:any) =>{
  get_evidence_case_Data(row.case_id);
  case_report_data.case_id = row.case_id;
  Ratification_Visible.value = true;
}
//查看立案报告表视图(主任)
const views_case_report_data_1 = (row:any) =>{
  case_report_data.case_id = row.case_id
  get_case_report_data(row);
  View_report_Visible_1.value = true;
}
//查看立案报告表视图（局长）
const views_case_report_data_2 = (row:any) =>{
  case_report_data.case_id = row.case_id
  get_case_report_data(row);
  View_report_Visible_2.value = true;
}


const query = reactive({
  case_source:'',
  case_type:'',
  tcs_note_id:'',
  case_number:'',
  pageIndex: 1,
  pageSize: 10
});


const case_state=reactive({
  temp:0,
  name:'',
})
const tableData = ref<TableItem[]>([]);
const tableList = ref<TableItem[]>([]); // 用于存放分页数据的列表
const pageTotal = ref(0);
const name = localStorage.getItem('ms_username');
// 获取表格数据
const getData = (archive_person:string='',case_id:number,case_source:string='',case_type:string='',case_number:string='',tcs_note_id:string='',name:string='') => {
  fetchData_case2(archive_person,case_id,case_source,case_type,case_number,tcs_note_id,name).then(res => {
    tableData.value = res.data.data.filter((i: { tcs_note_id: string; }) =>(
        i.tcs_note_id =="证据先行保存批准书已完成" ||
        i.tcs_note_id =="立案报告表已完成" ||
        i.tcs_note_id =="立案报告表主任审核已完成"
    )  )
    tableList.value = [];
    pageTotal.value = tableData.value.length || 0;
    // 根据页码确定下标位置
    const index: number = query.pageIndex * query.pageSize - query.pageSize;
    for (let i = index; i < index + query.pageSize; i++) {
      // 防止数组下标越界
      if (i <= tableData.value.length - 1) {
        tableList.value.push(tableData.value[i])
      } else {
        // 越界就不再循环
        break;
      }
    }
  });
};
getData('','','','','','',localStorage.getItem('ms_username'));
// 查询操作
const handleSearch = (case_number:string='',tcs_note_id:string='',case_source:string='',case_type:string='') => {
  getData('','',case_source,case_type,case_number,tcs_note_id,name);
};
// 分页导航
const handlePageChange = (val: number) => {
  query.pageIndex = val;
  getData('','','','','','',localStorage.getItem('ms_username'));
};
</script>

<style scoped>
.handle-box {
  margin-bottom: 20px;
}
.handle-box button{
  background-color: #00a854;
}
/*:deep .el-select-dropdown{*/
/*  max-width: 243px;*/
/*}*/
/*:deep .el-select-dropdown__item{*/
/*  display: inline-block;*/
/*}*/
/*.el-select-dropdown__item span {*/
/*  min-width: 205px;*/
/*  display: inline-block;*/
/*}*/


.handle-select {
  width: 120px;
}

.handle-input {
  width: 300px;
}
.table {
  width: 100%;
  font-size: 14px;
}
.red {
  color: #ff0000;
}

:deep(.avatar){
  width: 100px;
  height: 100px;
}
.blue {
  color: rgba(0, 118, 252, 0.79);
}
.mr10 {
  margin-right: 10px;
}
.table-td-thumb {
  display: block;
  margin: auto;
  width: 40px;
  height: 40px;
}

/*#inspect_record{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -20px;*/

/*}*/

/*#filing_report_review{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -22px;*/
/*}*/
</style>
